package com.cuanbobox.utils;

import android.view.View;
import android.view.ViewGroup;

import com.cuanbobox.widget.CmdRadioView;
import com.cuanbobox.widget.CmdSwitchTextView;
import com.cuanbobox.widget.CmdSwitchView;

public class ViewUtil {

    /**
     * 改变UI
     *
     * @param viewGroup 视图组
     * @param cmd       指令
     */
    public static void changUI(ViewGroup viewGroup, String cmd) {
        if (viewGroup == null) {
            return;
        }
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View view = viewGroup.getChildAt(i);
            if (view instanceof ViewGroup) {
                changUI((ViewGroup) view, cmd);
            } else if (view instanceof CmdSwitchView) {
                CmdSwitchView cmdSwitchView = (CmdSwitchView) view;
                cmdSwitchView.changeUI(cmd);
            } else if (view instanceof CmdSwitchTextView) {
                CmdSwitchTextView cmdTextView = (CmdSwitchTextView) view;
                cmdTextView.changeUI(cmd);
            } else if (view instanceof CmdRadioView) {
                CmdRadioView cmdTextView = (CmdRadioView) view;
                cmdTextView.changeUI(cmd);
            }
        }
    }

}
